Skip to main content

Post Convert Text To Speech

Welcome to the magic of turning words into a voice that speaks to the world! Imagine having a story to tell, an announcement to make, or just the joy of hearing a robot say "Hello, this is a test." The Convert Text To Speech (TTS) API endpoint is your gateway to achieving that and more.

Let’s dive into the details of how you can unleash this power.

Endpoint

Your journey begins here:

https://api.betatel.com/api/v1/tts

This endpoint transforms text into speech, bringing life to static words. Add your language preference and the text you wish to voice out—it’s that simple!

Headers

Every hero needs their tools, and in this case, it’s your headers:

ParamValueDescription
Content-typeapplication/jsonSpecifies the format of your payload.
x-api-key{{x-api-key}}Your unique API key for secure access.
x-user-id{{x-user-id}}Your user identifier for added security and tracking.

Request Body

Example of body
{"language":"en", "text":"Hello, this is a test."}
ParamTypeRequiredDescription
languagestringYesLanguage represents the language in which the text is written.
textstringYesText is the text that we want to translate into speech.

Code Snippets

Let’s get hands-on with some examples in different languages to see how easy it is to communicate with this endpoint. Choose your weapon of choice below!

Example - cURL
curl --location 'https://dev.api.betatel.com/api/v1/tts' \
--header 'x-user-id: 6757f3ffb5e62f0ce0e513a2' \
--header 'Content-Type: application/json' \
--header 'x-api-key: ••••••' \
--data '{"language":"en", "text":"Hello, this is a test."}'

Response

Upon a successful request, the API returns a downloadable .wav file containing the generated speech. This file can be used immediately or stored for future playback.

Response Format:

  • Content Type: audio/wav
  • Headers: Content-Disposition: attachment; filename="audio.wav" x-request-id: A unique identifier to track the request for debugging or verification. Content-Length: The size of the audio file in bytes.
HTTP/1.1 200 OK
Content-Type: audio/wav
Content-Disposition: attachment; filename="audio.wav"
Content-Length: 435678
x-request-id: 98f1b3d2-6e51-4c1d-bd4e-5f2a1c74fdae
  • Body: Binary audio data (.wav format)

Congratulations

You’ve just unlocked the art of voice generation. The possibilities are endless—from chatbots to audiobooks, dynamic announcements to accessibility features. Let your creativity lead the way as you breathe life into your text!